# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: fzerorubigd <fzero@rubi.gd>

pkgname=python-pgspecial
pkgver=2.1.0
pkgrel=2
pkgdesc='Meta-commands handler for PostgreSQL'
arch=('any')
url='https://github.com/dbcli/pgspecial'
license=('BSD')
depends=(
  'python'
  'python-click'
  'python-sqlparse'
  'python-psycopg'
)
makedepends=('git' 'python-setuptools')
checkdepends=('python-pytest' 'python-configobj')
_commit='d071787d9ed8da3424e43213e6695476923aebdc'
source=("$pkgname::git+$url.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  python setup.py build
}

check() {
  cd "$pkgname"

  PYTHONPATH="$(pwd):$PYTHONPATH" pytest --ignore tests/test_specials.py
}

package() {
  cd "$pkgname"

  python setup.py install --root="$pkgdir" --optimize=1 --skip-build

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.rst

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" License.txt
}
